<template>
  <div class="layui-layout layui-layout-admin">
    <div class="adminnav1">
      <Pagetop></Pagetop>
    </div>
    <div class="adminnav2">
      <Secondnav urlname="user"></Secondnav>
    </div>

    <!-- 主体内容 -->
    <div class="layui-body kedou-admin" id="LAY_app_body app">
      <div class="layadmin-tabsbody-item layui-show">
        <div class="pagelist">
          <div class="layui-tab layui-tab-card">
            <ul class="layui-tab-title">
              <li class="layui-this" @click='getdata("shopli")'>编辑门店信息</li>
              <li @click='getdata("lbli")'>编辑轮播广告图片</li>
              <li @click='getdata("xcli")'>编辑相册图片</li>
              <li @click='getdata("bjli")'>编辑背景图片</li>
              <li @click='getdata("ewmli")'>编辑二维码图片</li>
            </ul>
            <div class="layui-tab-content" style="padding:50px 0;font-size:14px">
              <div class="layui-tab-item layui-show">
                <!-- <div class="layui-card-body">
            <fieldset class="layui-elem-field layui-field-title">
              <legend>{{ storetitle }}</legend>
            </fieldset>
                </div>-->
                <div class="layui-card-body">
                  <div class="layui-form" lay-filter>
                    <div class="layui-form-item gredit" v-show="isshow != 0">
                      <label class="layui-form-label">门店账号</label>
                      <div class="layui-input-block">
                        <input
                          type="text"
                          name="userName"
                          placeholder="门店账号"
                          disabled="disabled"
                          v-model="itemData.userName"
                          autocomplete="off"
                          class="layui-input"
                        />
                      </div>
                    </div>
                    <div class="layui-form-item gredit" v-show="isshow != 0">
                      <label class="layui-form-label">密码</label>
                      <div class="layui-input-block">
                        <input
                          type="password"
                          name="userPassword"
                          placeholder="门店账号"
                          v-model="itemData.userPassword"
                          autocomplete="off"
                          class="layui-input"
                          maxlength="6"
                        />
                      </div>
                    </div>
                    <div class="layui-form-item gredit" v-show="isshow != 0">
                      <label class="layui-form-label">支付密码</label>
                      <div class="layui-input-block">
                        <input
                          type="password"
                          name="accountPassword"
                          placeholder="门店账号"
                          v-model="itemData.accountPassword"
                          autocomplete="off"
                          class="layui-input"
                          maxlength="6"
                        />
                      </div>
                    </div>
                    <!---->
                    <div class="layui-form-item" v-show="isshow != 0">
                      <label class="layui-form-label">手机号码</label>
                      <div class="layui-input-block" style="width: 180px;">
                        <input
                          type="number"
                          name="userMobile"
                          placeholder="输入手机号码"
                          v-model="itemData.userMobile"
                          autocomplete="off"
                          class="layui-input"
                          maxlength="11"
                        />
                      </div>
                    </div>
                    <div class="layui-form-item">
                      <label class="layui-form-label">门店名称</label>
                      <div class="layui-input-block" style="width: 180px;">
                        <input
                          type="text"
                          name="name"
                          placeholder="输入门店名称"
                          v-model="itemData.name"
                          autocomplete="off"
                          class="layui-input a"
                        />
                      </div>
                    </div>
                    <div class="layui-form-item">
                      <label class="layui-form-label">手机号码</label>
                      <div class="layui-input-block" style="width: 180px;">
                        <input
                          type="number"
                          name="mobile"
                          placeholder="输入手机号码"
                          v-model="itemData.dealer.mobile"
                          autocomplete="off"
                          class="layui-input"
                          maxlength="11"
                        />
                      </div>
                    </div>
                    <div class="layui-form-item">
                      <div class="layui-inline">
                        <label class="layui-form-label">商品图片</label>
                        <div class="layui-input-inline" style="width: 180px;">
                          <div class="layui-upload">
                            <button
                              type="button"
                              class="layui-btn"
                              id="layuiadmin-upload-useradmin"
                            >选择文件</button>
                          </div>
                        </div>
                      </div>
                    </div>
                    <div class="layui-form-item">
                      <div class="layui-inline">
                        <label class="layui-form-label">图片预览</label>
                        <div class="layui-input-inline" style="width: 180px;">
                          <img
                            id="img"
                            :src="
                        itemData.rotationPictures
                          ? itemData.rotationPictures
                          : require('@/assets/zwyl.jpg')
                      "
                            style="width:100px;height:100px;"
                          />
                        </div>
                      </div>
                    </div>
                    <div
                      class="layui-form-item editshopType"
                      v-show="addshopType == 1"
                      style="display:none;"
                    >
                      <label class="layui-form-label">店铺类型</label>
                      <div class="layui-input-inline">
                        <select
                          name="shopTypeId"
                          lay-filter="shopTypeId"
                          v-model="itemData.shopTypeId"
                        >
                          <option value="1">个体店</option>
                          <option value="2">连锁店总店</option>
                          <option value="3">直营连锁店</option>
                          <option value="4">加盟连锁店</option>
                          <option value="5">虚拟店</option>
                        </select>
                      </div>
                    </div>
                    <div
                      class="layui-form-item addshopType"
                      v-show="addshopType == 0"
                      style="display:none;"
                    >
                      <label class="layui-form-label">店铺类型</label>
                      <div class="layui-input-inline">
                        <select
                          name="shopTypeId"
                          lay-filter="shopTypeId"
                          v-model="itemData.shopTypeId"
                        >
                          <option v-for="(val, key, index) in shopTypelist" :value="key">{{ val }}</option>
                        </select>
                      </div>
                    </div>
                    <div class="layui-form-item">
                      <label class="layui-form-label">行业类型</label>
                      <div class="layui-input-inline">
                        <select name="tradeId" lay-filter="tradeId" v-model="itemData.tradeId">
                          <option :value="items.id" v-for="items in tradeList">{{items.name}}</option>
                        </select>
                      </div>
                    </div>
                    <div class="layui-form-item">
                      <label class="layui-form-label">经营类目</label>
                      <div class="layui-input-inline">
                        <select name="categoryIds" lay-filter="categoryIds" v-model="itemData.categoryIds">
                          <option :value="items.id" v-for="items in categorylist">{{items.name}}</option>
                        </select>
                      </div>
                    </div>
                    <!--<div class="layui-form-item">
							 <label class="layui-form-label">人均消费</label>
						    <div class="layui-input-block">
						        <input type="number" name="perPersonConsumption" placeholder="输入人均消费"   v-model="itemData.perPersonConsumption" autocomplete="off" class="layui-input a">
						    </div>	
                    </div>-->
                    <!--<div class="layui-form-item">
							<input type="hidden" name="regionId" id="regionId" value="">
							<label class="layui-form-label">商圈</label>
							    <div class="layui-input-block">
							    	
						    		<div class="fllist">
						    			<ul v-if="regionList[0].length>0">
						    				<li :class="regioncur[0]==item.id?'cur':''" v-for="item in regionList[0]" @click="getRegion(item.id,1,item.name)">{{item.name}}</li>
						    			</ul>
						    			<ul v-if="regionList[1].length>0">
						    				<li :class="regioncur[1]==item.id?'cur':''" v-for="item in regionList[1]" @click="getRegion(item.id,2,item.name)">{{item.name}}</li>					   				
						    			</ul>
						    			<ul v-if="regionList[2].length>0">
						    				<li :class="regioncur[2]==item.id?'cur':''" v-for="item in regionList[2]" @click="getRegion(item.id,3,item.name)">{{item.name}}</li>
						    			</ul>						    									    										    			
						    		</div>
							    </div>							
                    </div>-->
                    <!--<div class="layui-form-item">
							 <label class="layui-form-label">经度</label>
						    <div class="layui-input-block">
						        <input type="text" name="longitude" placeholder="输入经度"   v-model="itemData.longitude" autocomplete="off" class="layui-input a">
						    </div>	
						</div>
						<div class="layui-form-item">
							 <label class="layui-form-label">纬度</label>
						    <div class="layui-input-block">
						        <input type="text" name="latitude" placeholder="输入纬度	"   v-model="itemData.latitude" autocomplete="off" class="layui-input a">
						    </div>	
                    </div>-->
                    <div class="layui-form-item">
                      <label class="layui-form-label">获取坐标</label>
                      <div class="layui-input-block">
                        <div class="layui-upload">
                          <a
                            target="_blank"
                            href="http://api.map.baidu.com/lbsapi/getpoint/index.html"
                          >
                            <button type="button" class="layui-btn layui-btn-danger">通过百度地图获取坐标</button>
                          </a>
                        </div>
                      </div>
                    </div>
                    <div class="layui-form-item">
                      <label class="layui-form-label">详细地址</label>
                      <div class="layui-input-inline">
                        <input
                          type="text"
                          name="address"
                          placeholder="输入地址"
                          v-model="itemData.address"
                          autocomplete="off"
                          class="layui-input a"
                        />
                      </div>
                    </div>
                    <div class="layui-form-item">
                      <label class="layui-form-label">门店详情</label>
                      <div class="layui-input-block">
                        <div class="layui-upload">
                          <button type="button" class="layui-btn" id="test2">多图片上传</button>

                          <blockquote
                            class="layui-elem-quote layui-quote-nm"
                            style="margin-top: 10px;"
                          >
                            <div class="layui-upload-list uploader-list">
                              <div class="li" v-for="(item,index) in imglist" :key="index">
                                <img class="close" @click="del(index)" src="../../../assets/delete.png"/>
                                <img class="mapimg" :src="item" />
                              </div>
                            </div>
                          </blockquote>
                        </div>
                      </div>
                    </div>

                    <div class="layui-form-item">
                      <div class="layui-input-block">
                        <button
                          class="layui-btn layui-btn-normal"
                          lay-submit
                          lay-filter="setmyinfo"
                          @click="confirmOk"
                        >确认</button>
                      </div>
                    </div>
                  </div>
                </div>
              </div>

              <div class="layui-tab-item" style="font-size:14px">
                <div class="layui-form" lay-filter>

                  <div class="layui-form-item">
                    <label class="layui-form-label">轮播图片</label>
                    <div class="layui-input-block">
                      <div class="layui-upload">
                        <button type="button" class="layui-btn" id="test3" >多图片上传</button>

                        <blockquote
                          class="layui-elem-quote layui-quote-nm"
                          style="margin-top: 10px;"
                        >
                          <div class="layui-upload-list uploader-list">
                            <div class="li" v-for="(item,index) in piclist" :key="index">
                              <img class="close" @click="dels(index)" src="../../../assets/delete.png"/>
                              <img class="mapimg" :src="item" />
                            </div>
                          </div>
                        </blockquote>
                      </div>
                    </div>
                  </div>
                </div>
              </div>

              <div class="layui-tab-item" style="font-size:14px">
                <div class="layui-form" lay-filter>
                  <div class="layui-form-item">
                    <label class="layui-form-label">相册</label>
                    <div class="layui-input-block">
                      <div class="layui-upload">
                        <button type="button" class="layui-btn" id="test4">多图片上传</button>

                        <blockquote
                          class="layui-elem-quote layui-quote-nm"
                          style="margin-top: 10px;"
                        >
                          <div class="layui-upload-list uploader-list">
                            <div class="li" v-for="(item,index) in urllist" :key="index">
                              <img class="close" @click="delss(index)" src="../../../assets/delete.png"/>
                              <img class="mapimg" :src="item" />
                            </div>
                          </div>
                        </blockquote>
                      </div>
                    </div>
                  </div>
                </div>
              </div>

              <div class="layui-tab-item" style="font-size:14px">
                <div class="layui-form" lay-filter>
                  <div class="layui-form-item">
                    <div class="layui-inline">
                      <label class="layui-form-label">名称</label>
                      <div class="layui-input-inline">
                        <input
                          type="text"
                          name="name"
                          v-model="bjData.name"
                          placeholder
                          autocomplete="off"
                          class="layui-input"
                        />
                      </div>
                    </div>
                  </div>

                  <div class="layui-form-item">
                    <label class="layui-form-label">详情</label>
                    <div class="layui-input-block" style="width:280px">
                      <textarea
                        placeholder="请输入内容"
                        class="layui-textarea"
                        v-model="bjData.details"
                      ></textarea>
                    </div>
                  </div>

                  <div class="layui-form-item">
                      <div class="layui-inline">
                        <label class="layui-form-label">背景图片</label>
                        <div class="layui-input-inline" style="width: 180px;">
                          <div class="layui-upload">
                            <button
                              type="button"
                              class="layui-btn"
                              id="layuiadmin-upload-useradmin1"
                            >选择文件</button>
                          </div>
                        </div>
                      </div>
                    </div>
                    <div class="layui-form-item">
                      <div class="layui-inline">
                        <label class="layui-form-label">图片预览</label>
                        <div class="layui-input-inline" style="width: 180px;">
                          <img
                            id="imgs"
                            :src="
                        bjData.logo
                          ? bjData.logo
                          : require('@/assets/zwyl.jpg')
                      "
                            style="width:100px;height:100px;"
                          />
                        </div>
                      </div>
                    </div>
                </div>
                <div class="layui-form-item">
                  <div class="layui-input-block" style="margin-left:10%;margin-top:20px;">
                    <button class="layui-btn layui-btn-normal" @click="bjsure()">保存设置</button>
                  </div>
                </div>
              </div>

              <div class="layui-tab-item" style="font-size:14px">
                <div class="layui-form" lay-filter>
                  <div class="layui-form-item">
                    <div class="layui-inline">
                      <label class="layui-form-label">名称</label>
                      <div class="layui-input-inline">
                        <input
                          type="text"
                          name="name"
                          v-model="ewmData.name"
                          placeholder
                          autocomplete="off"
                          class="layui-input"
                        />
                      </div>
                    </div>
                  </div>

                  <div class="layui-form-item">
                    <label class="layui-form-label">详情</label>
                    <div class="layui-input-block" style="width:280px">
                      <textarea
                        placeholder="请输入内容"
                        class="layui-textarea"
                        v-model="ewmData.details"
                      ></textarea>
                    </div>
                  </div>

                  <div class="layui-form-item">
                      <div class="layui-inline">
                        <label class="layui-form-label">二维码图片</label>
                        <div class="layui-input-inline" style="width: 180px;">
                          <div class="layui-upload">
                            <button
                              type="button"
                              class="layui-btn"
                              id="layuiadmin-upload-useradmin2"
                            >选择文件</button>
                          </div>
                        </div>
                      </div>
                    </div>
                    <div class="layui-form-item">
                      <div class="layui-inline">
                        <label class="layui-form-label">图片预览</label>
                        <div class="layui-input-inline" style="width: 180px;">
                          <img
                            id="img2"
                            :src="
                        ewmData.logo
                          ? ewmData.logo
                          : require('@/assets/zwyl.jpg')
                      "
                            style="width:100px;height:100px;"
                          />
                        </div>
                      </div>
                    </div>
                </div>
                <div class="layui-form-item">
                  <div class="layui-input-block" style="margin-left:10%;margin-top:20px;">
                    <button class="layui-btn layui-btn-normal" @click="ewmsure()">保存设置</button>
                  </div>
                </div>
              </div>

            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import Pagetop from "../../common/pagetop.vue";
import Secondnav from "../../common/secondnav.vue";
import Vue from "vue";
export default {
  name: "storedit",
  components: { Pagetop, Secondnav },
  data() {
    return {
      id: "",
      itemData: {
        userName: "",
        userPassword: "",
        accountPassword: "",
        userMobile: "",
        phone: "",
        name: "",
        imgurl: "",
        dealer:{mobile:''},
        addressMap: "",
        longitude: 0,
        latitude: 0,
        categoryIds: "", //经营分类
        tradeId: "", //行业
        shopTypeId: { id: "0" }, //店铺类型
      },
      tradeList: [],
      categorylist: [], //经营类目
      regionList: [[], [], [], []],
      regioncur: [],
      isshow: 0,
      level: localStorage.getItem("level"),
      name1: "",
      name2: "",
      name3: "",
      provinceId: "",
      cityId: "",
      areaId: "",
      storetitle: "",
      addshopType: "0",
      shopTypelist: {},
      imglist: [],
      piclist: [],
      lbdata: [],
      lball:'',
      urllist: [],
      xcdata: [],
      xcall:'',
      bjData: {
        details: "",
        logo: "",
        name: "",
        type:{
          id:'',
          name:''
        }
      },
      ewmData: {
        details: "",
        logo: "",
        name: "",
        type:{
          id:'',
          name:''
        }
      },
    };
  },
  mounted() {
    var _this = this;
    window.getdata = this.getdata;
    layui.use(["upload", "element"], function () {
      var upload = layui.upload;
      var element = layui.element;
      var uploadInst = upload.render({
        elem: "#layuiadmin-upload-useradmin", //绑定元素
        data: {
          type: 2,
        },
        url: imguploadurl, //上传接口
        done: function (res) {
          layer.msg("上传成功");
          _this.itemData.imgurl = res.msg;
        },
        error: function () {
          layer.msg("上传失败");
        },
      });
      upload.render({
        elem: "#test2",
        data: {
          type: 2,
        },
        url: "http://storage.g2ma.com/imgUpload/multi",
        multiple: true,
        before: function (obj) {},
        done: function (res,index) {
          layer.msg("上传成功");
          var arr = _this.imglist;
          arr.push(res.msg);
          this.imglist = arr;
          if(_this.imglist.length == 9){
            layer.msg("详情图片不能超过9张");
            return false
          }
          
        },
      });
      upload.render({
        elem: "#test3",
        data: {
          type: 2,
        },
        url: "http://storage.g2ma.com/imgUpload/multi",
        multiple: true,
        before: function (obj) {},
        done: function (res) {
          // alert(res.msg)
          setTimeout(function(){
            if (_this.lbdata.length == 3) {
            layer.msg("轮播图片不能超过3张");
            return false;
               }
            var dates = {
                     title: '',
                     picUrl:  res.msg,
                     targetUrl: "",
                     advertType: {id: 5},
                     rank: 1,
                     shopId: _this.id,
                     targetType: 2,
                     targetId: "0",
                     appointed: ""
                          }
               var url = "/advert/bapi/v1.9/advert";
            ajaxRequest(url, "POST", "json", dates, function (ret, err) {
                layer.msg("上传成功");
                 _this.getdata();
                   });
             },1000)

        },
      });
      upload.render({
        elem: "#test4",
        data: {
          type: 2,
        },
        url: "http://storage.g2ma.com/imgUpload/multi",
        multiple: true,
        before: function (obj) {},
        done: function (res) {
          // layer.msg("上传成功");
          // alert(res.msg)
          setTimeout(function () {
              var dates = {
                     picUrl: res.msg,
                     targetUrl: "",
                     advertType: {id: 7},
                     rank: 1,
                     shopId: _this.id,
                     targetType: 2,
                     targetId: "0",
                     appointed: ""
                     }
             var url = "/advert/bapi/v1.9/advert";
              ajaxRequest(url, "POST", "json", dates, function (ret, err) {
                    layer.msg("上传成功");
                    _this.getdata();
                         });
          },1000)
        },
      });
      upload.render({
        elem: "#layuiadmin-upload-useradmin1", //绑定元素
        data: {
          type: 2,
        },
        url:imguploadurl, //上传接口
        done: function (res) {
          layer.msg("上传成功");
          _this.bjData.logo = res.msg;
        },
        error: function () {
          layer.msg("上传失败");
        },
      });
      upload.render({
        elem: "#layuiadmin-upload-useradmin2", //绑定元素
        data: {
          type: 2,
        },
        url:imguploadurl, //上传接口
        done: function (res) {
          layer.msg("上传成功");
          _this.ewmData.logo = res.msg;
        },
        error: function () {
          layer.msg("上传失败");
        },
      });
    });
    if (this.level != 0) {
      this.isshow == 1;
    }
    if (this.$route.query.id) {
      this.id = this.$route.query.id;
      this.storetitle = "编辑门店信息";
      this.addshopType = 1;
      this.getdata("shopli");
      this.getpic();
      this.stortlist();
      this.categoryhx();
    } else {
      this.storetitle = "创建门店信息";
      this.addshopType = 0;
      this.shopType(); //店铺类型
      this.stortlist();
    }
    // this.getdata("shopli");
  },
  methods: {
    del: function (index) {
      var _this = this;
      var arr = _this.imglist;
      // var narr= arr.splice(index)
      arr.splice(index, 1);
      _this.imglist = arr;
      // alert(JSON.stringify(_this.imglist))
    },
    dels: function (index) {
      var _this = this;
      var arr = _this.lbdata[index].id;
      layer.confirm("是否确认删除？", function () {
        var url = "/advert/bapi/v1.9/advert/" + arr;
        ajaxRequest(url, "DELETE", "json", "", function (ret, err) {
          layer.msg("操作成功");
          setTimeout(function () {
            _this.getdata();
          }, 1000);
        });
      });
    },
    delss: function (index) {
      var _this = this;
      var arr = _this.xcdata[index].id;
      layer.confirm("是否确认删除？", function () {
        var url = "/advert/bapi/v1.9/advert/" + arr;
        ajaxRequest(url, "DELETE", "json", "", function (ret, err) {
          layer.msg("操作成功");
          setTimeout(function () {
            _this.getdata();
          }, 1000);
        });
      });
    },
    getdata: function (type) {
      var _this = this;
      var dates = {
        id: _this.id,
      };
      var url = "/shop/papi/v1.9/shops/" + _this.id;
      if (type == "shopli") {
        ajaxRequest(url, "GET", "json", "", function (ret, err) {
          // alert(url + "//" + JSON.stringify(ret));

          _this.itemData = ret.data; //门店信息
          _this.gettrade(); //行业分类
          //_this.getcategory();//经营类目
          		    	// _this.tradeList=ret.content.tradeList;//行业
          //		    	_this.regionList[0]=ret.content.regionList;//地区
          if (ret.data.addressMap != "" && ret.data.addressMap != null ) {
            var pic = [];
            var src = ret.data.addressMap;

            if (src.indexOf(",") > 0) {
              pic = src.split(",");
              _this.imglist = pic;
            } else {
              pic[0] = src;
              _this.imglist = pic;
            }
          }
        });
      } else if (type == "lbli"){
        var purl = "/advert/papi/v1.9/advert/type/5/" + _this.id;
        ajaxRequest(purl, "GET", "json", "", function (ret, err) {
          _this.lbdata = ret.data
          var arr = ret.data
          var parr = []
          for(var i= 0; i<arr.length;i++){
            parr.push(arr[i].picUrl)
          }
          _this.piclist = parr
          
        });
      }else if(type == 'xcli'){
        var purl = "/advert/papi/v1.9/advert/type/7/" + _this.id;
        ajaxRequest(purl, "GET", "json", "", function (ret, err) {
           _this.xcdata = ret.data
          var arr = ret.data
          var parr = []
          for(var i= 0; i<arr.length;i++){
            parr.push(arr[i].picUrl)
          }
          _this.urllist = parr
        });
      }else if(type == 'bjli'){
        var _this = this;
        var url = "/advert/bapi/v1.9/apply-setting/byType/1";
        ajaxRequest(url, "GET", "json", "", function (ret, err) {
          if (ret.data.length > 0) {
            _this.bjData = ret.data[0];
          }
        });
      }else{
        var purl = "/advert/bapi/v1.9/apply-setting/byType/2";
        ajaxRequest(purl, "GET", "json", "", function (ret, err) {
          if (ret.data.length > 0) {
            _this.ewmData = ret.data[0];
          }
        });
      }
    },
    getpic: function () {
      var _this = this;
      var url = "/advert/papi/v1.9/apply-setting/backType/all";
      ajaxRequest(url, "GET", "json", "", function (ret, err) {
        var arr = ret.data
       _this.bjData.type.id = arr[0].id
      _this.ewmData.type.id  = arr[1].id
      });
    },
    gettrade: function () {},
    categoryhx: function () {
      var _this = this;
      var url = "/mall/bapi/v1.9/shop/category/" + _this.id;
      ajaxRequest(url, "GET", "json", "", function (ret, err) {
        _this.categorylist = ret.data;
        //          	var ids="";
        //		        var names="";
        //		        var ret=res.data;
        //		        for(var i=0;i<ret.length;i++){
        //		          ids=ids+ret[i].id+","
        //		          names=names+ret[i].name+","
        //		        }
      });
    },
    getcategory: function () {
      //经营分类的列表
      var _this = this;
      var url = "/commodity/bapi/v2.0/categories/self";
      ajaxRequest(url, "GET", "json", "", function (ret, err) {
        _this.categorylist = ret.data;
      });
    },
    shopType: function () {
      var _this = this;
      //	    	var url="/huanxinsong/store/getshopTypes";
      //	    	ajaxRequest(url,'GET','json','',function(ret,err){
      //	    		//alert(url+"//"+JSON.stringify(ret))
      //	    		_this.shopTypelist=ret;
      //	    	})
    },
    stortlist: function () {
      var _this = this;
      var url = "/hxs/store/getTradeListByParentId" ;
      //	    	var url="/huanxinsong/store/editJson/1";
      	    	ajaxRequest(url,'GET','json','',function(ret,err){
      	    		// alert(JSON.stringify(ret))
      	    		_this.tradeList=ret;//行业
      	    		// _this.tradeList=ret.content.tradeList;//行业
      	    		// _this.itemData.tradeId=ret.content.tradeList[0].id;
      	    		// _this.regionList[0]=ret.content.regionList;//地区
              },'wfw')
             
    },
    getRegion: function (pid, index, name) {
      //选省市区
      //	    	if(index==1){
      //	    	   this.itemData.address='';
      //	    	}
      var c = this.itemData.address;
      if (index == 1) {
        this.provinceId = pid;
        this.name1 = name;
        this.name2 = "";
        this.name3 = "";
      } else if (index == 2) {
        this.cityId = pid;
        this.name2 = name;
        this.name3 = "";
      } else if (index == 3) {
        this.areaId = pid;
        this.name3 = name;
      }
      if (pid != 1) {
        this.itemData.regionId = pid;
        this.regioncur[index - 1] = pid;
        //this.itemData.address=c+name;
      }
      this.itemData.address = this.name1 + this.name2 + this.name3;
      var _this = this;
      var data = {
        parentId: pid,
      };
      //	  		var url = "/huanxinsong/proxyregion/getRegionListByParentId";
      //	  		ajaxRequest(url,'GET','json',data,function(ret,err){
      //	  			//alert(JSON.stringify(ret))
      //	  			for(var i=index;i<3;i++){
      //	  			 	var arr=[];
      //	  			 	Vue.set(_this.regionList,i,arr);
      //	  			}
      //	  		    Vue.set(_this.regionList,index,ret)
      //
      //	  		})
    },
    confirmOk: function () {
      //console.log(JSON.stringify(this.itemData))
      var _this = this;
      //   var len = $(".a").length;
      //   for (var i = 0; i < len; i++) {
      //     if (
      //       $(".a")
      //         .eq(i)
      //         .val() == "" ||
      //       $(".a")
      //         .eq(i)
      //         .val() < 0
      //     ) {
      //       var msg = $(".a")
      //         .eq(i)
      //         .attr("placeholder");
      //       layer.msg("请输入正确的" + msg);
      //       return;
      //     }
      //   }
      //   if (_this.level != 0) {
      //     if (_this.itemData.userName) {
      //       later.msg("请输入门店账号");
      //       return false;
      //     }
      //     if (_this.itemData.userPassword) {
      //       later.msg("请输入密码");
      //       return false;
      //     }
      //     if (_this.itemData.accountPassword) {
      //       later.msg("请输入支付密码");
      //       return false;
      //     }
      //   }
      //   if (!this.itemData.shopTypeId) {
      //     layer.msg("请选择店铺类型");
      //     return false;
      //   }
      //   if (!this.itemData.tradeId) {
      //     layer.msg("请选择行业类型");
      //     return false;
      //   }

      //   if (!this.itemData.regionId) {
      //     layer.msg("请选择商圈");
      //     return false;
      //   }
      if (_this.imglist.length > 9) {
            layer.msg("详情图片不能超过9张");
            return false;
          }
      var hat = "POST";
      var dates = this.itemData;
      dates.addressMap = String(_this.imglist);
      if (this.id) {
        dates.id = this.id;
        hat = "PUT";
      }

      var url = "/shop/bapi/v1.9/shops/";
      ajaxRequest(url, hat, "json", dates, function (ret, err) {
        layer.msg("操作成功");
        setTimeout(function () {
          _this.$router.push({ path: "/storelist" });
        }, 1000);
      });
    },
    bjsure: function () {
      var _this = this;
      var dates = _this.bjData;
      var url = "/advert/bapi/v1.9/apply-setting/createOrUpdate";
      ajaxRequest(url, "POST", "json", dates, function (ret, err) {
        layer.msg("操作成功");
        setTimeout(function () {
          var index = parent.layer.getFrameIndex(window.name);
          parent.layer.close(index);
          parent.location.reload();
        }, 1000);
      });
    },
    ewmsure: function () {
      var _this = this;
      var dates = _this.ewmData;
      var url = "/advert/bapi/v1.9/apply-setting/createOrUpdate";
      ajaxRequest(url, "POST", "json", dates, function (ret, err) {
        layer.msg("操作成功");
        setTimeout(function () {
          var index = parent.layer.getFrameIndex(window.name);
          parent.layer.close(index);
          parent.location.reload();
        }, 1000);
      });
    },
  },

   
  updated: function () {
    var _this = this;
    layui.use("form", function () {
      var form = layui.form;
      form.render();
      form.on("select(shopTypeId)", function (data) {
        _this.itemData.shopTypeId = data.value;
      });
      form.on("select(tradeId)", function (data) {
        _this.itemData.tradeId = data.value;
      });
      form.on("select(categoryIds)", function (data) {
        //类目
        _this.itemData.categoryIds = data.value;
        // _this.getcategory();
      });
      form.on("select(regionId)", function (data) {
        _this.itemData.regionId = data.value;
      });
    });
  },
};
</script>
<style>
#J_imageView img {
  width: 400px;
  display: block;
}
.layuiregion {
  width: 150;
  float: left;
}
.fllist ul {
  display: inline-block;
  width: 20%;
  height: 120px;
  margin-right: 1%;
  overflow: hidden;
  overflow-y: scroll;
  border: 1px solid #eee;
}
.fllist ul li {
  height: 30px;
  line-height: 30px;
  padding: 5px 20px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
}
.fllist ul li.cur {
  background-color: #3276df;
  color: #fff;
}
#demo2 img {
  display: inline-block;
  margin-right: 10px;
  width: 100px;
  height: 100px;
}
.uploader-list {
  margin-left: -15px;
}

.uploader-list .li {
  position: relative;
  width: 100px;
  height: 100px;
  display: inline-block;
  margin-left: 15px;
}

.li .mapimg {
  width: 100px;
  height: 100px;
  position: absolute;
}
.li .close {
  position: relative;
  width: 15px;
  left: 8px;
  bottom: 10px;
  float: right;
  z-index: 1000;
}
</style>
